package com.xmg.p2p.business.service.impl;

import com.xmg.p2p.base.query.PageResult;
import com.xmg.p2p.business.domain.PlatformBankInfo;
import com.xmg.p2p.business.mapper.PlatformBankInfoMapper;
import com.xmg.p2p.business.query.PlatformBankInfoQueryObject;
import com.xmg.p2p.business.service.IPlatformBankInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * lcd  2020/5/26
 * Description:
 */
@Service
public class PlatformBankInfoServiceImpl implements IPlatformBankInfoService {
    @Autowired
    private PlatformBankInfoMapper platformBankInfoMapper;
    @Override
    public PageResult query(PlatformBankInfoQueryObject qo) {
        int i = platformBankInfoMapper.queryForCount(qo);
        if (i > 0) {
            return new PageResult(platformBankInfoMapper.query(qo), i, qo.getCurrentPage(), qo.getPageSize());
        }
        return PageResult.empty(qo.getPageSize());
    }

    @Override
    public void saveOrUpdate(PlatformBankInfo platformBankInfo) {
        if (platformBankInfo.getId() == null) {
            platformBankInfoMapper.insert(platformBankInfo);
        }else {
            platformBankInfoMapper.updateByPrimaryKey(platformBankInfo);
        }
    }

    @Override
    public List<PlatformBankInfo> findAll() {
        return platformBankInfoMapper.selectAll();
    }
}
